﻿using Project_mfa.entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Project_mfa
{
    public partial class WebForm1 : System.Web.UI.Page
    {

        private Logging log;

        protected void Page_Load(object sender, EventArgs e)
        {
            log = new Logging();
            getFestival(Request.QueryString["id"]);
        }

        protected void getFestival(String id)
        {

            int selected = Convert.ToInt32(id);

            Data db = new Data();

            try
            {
                foreach (getFestival_Result item in db.eGetFestival(selected))
                {
                    resultFest.Controls.Add(new LiteralControl("<div class='row'><div class='col col_16'><h1>" + item.fest_naam + "</h1></div></div>"));
                    resultFest.Controls.Add(new LiteralControl("<div class='row'><div class='col col_5'> Date: " + item.fest_datum + "</div><div class='col col_5'>Duration: " + item.fest_duur + " hours </div></div>"));
                    resultFest.Controls.Add(new LiteralControl("<div class='row'><div class='col col_7'><br/> Location: " + item.fest_locatie + "<br/><br/></div></div>"));
                    resultFest.Controls.Add(new LiteralControl("<div class='row'><div class='col col_7'><div id='map'></div><small>address is approximate</small></div>"));
                    resultFest.Controls.Add(new LiteralControl("<script> $(document).ready(function() {$('#map').geocode({address: '" + item.fest_locatie + "', zoom: 16});});</script> "));

                }

                resultFest.Controls.Add(new LiteralControl("<div class='col col_8'><h3>Lineup</h3><br/>"));
                resultFest.Controls.Add(new LiteralControl("<table><tr><th>Name</th><th>Date</th><th>Hour</th><th>Stage</th><tr>"));

                foreach (getFestivalBands_Result item in db.eGetFestivalBands(selected))
                {
                    resultFest.Controls.Add(new LiteralControl("<tr>"));
                    resultFest.Controls.Add(new LiteralControl("<td>"));

                    //LinkButton bandLink = new LinkButton();
                    //bandLink.ID = "bandLink" + item.band_id;
                    HyperLink bandLink = new HyperLink();
                    bandLink.NavigateUrl = "Band.aspx?id=" + item.band_id;
                    bandLink.Text = item.band_naam;

                    resultFest.Controls.Add(bandLink);

                    resultFest.Controls.Add(new LiteralControl("</td>"));
                    resultFest.Controls.Add(new LiteralControl("<td>" + item.datum + "</td>"));
                    resultFest.Controls.Add(new LiteralControl("<td>" + item.uur + "</td>"));
                    resultFest.Controls.Add(new LiteralControl("<td>" + item.podium + "</td>"));
                    resultFest.Controls.Add(new LiteralControl("</tr>"));
                }

                resultFest.Controls.Add(new LiteralControl("</table></div></div><div class='row'><div class='col col_10'></br><h3>Camping</h3></br></div></div>"));
                resultFest.Controls.Add(new LiteralControl("<div class='row'><div class='col col_5'><strong>address</strong></div><div class='col col_5'><strong>Capacity</strong></div></div>"));

                foreach (getFestivalCampings_Result item in db.eGetFestivalCampings(selected))
                {
                    resultFest.Controls.Add(new LiteralControl("<div class='row'>"));
                    resultFest.Controls.Add(new LiteralControl("<div class='col col_5'>" + item.camp_adres + "</div><div class='col col_5'>" + item.camp_cap + "</div>"));
                    resultFest.Controls.Add(new LiteralControl("</div>"));
                    resultFest.Controls.Add(new LiteralControl("<div class='row hide'>"));

                    resultFest.Controls.Add(new LiteralControl("<table class='minTable'><tr><th>Facility</th><th>Price</th><th>amount</th></tr>"));

                    foreach (getCampFaci_Result tussen in db.eGetCampFaci(item.camp_id))
                    {
                        resultFest.Controls.Add(new LiteralControl("<tr><td>" + tussen.fac_omschrijving + "</td><td>" + tussen.fac_eenhprijs + "</td><td>" + tussen.aantal + "</td></tr>"));
                    }

                    resultFest.Controls.Add(new LiteralControl("</table></div>"));
                }
            }
            catch (Exception e)
            {
                log.WriteLine("Festival", e.Message);
            }

        }
    }
}